package cn.dgfy.BaseSpringBootWebProj.controller;

import cn.dgfy.BaseSpringBootWebProj.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class DemoController {
	
	private final DemoService demoService;
	
	@Autowired
	public DemoController(DemoService demoService) {
		this.demoService = demoService;
	}
	
	@RequestMapping("/demo")
	public String demo(@RequestParam(value = "name", required = false, defaultValue = "World") String name, Model model) {
		System.out.println(demoService == null ? "demoService is null" : "demoService is not null");
		model.addAttribute("name",name);
		return "hello";
	}
}
